package com.youku.parser;

import java.io.File;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class XmlAnalysizer {

	private static final Logger logger = LoggerFactory.getLogger(XmlAnalysizer.class);

	private Document[] documents;

	public XmlAnalysizer(String... location) {
		SAXReader reader = new SAXReader();

		try {
			documents = new Document[location.length];
			for (int i = 0; i < location.length; i++) {
				documents[i] = reader.read(new File(location[i]));
			}
		} catch (DocumentException e) {
			throw new RuntimeException(e);
		}
	}

	public void analysis() {
		for (Document document : documents) {
			Element root = document.getRootElement();

			Element project = root.element("project");

			String projectId = project.attributeValue("id");
			
			logger.info("项目id:" + projectId);
		}
	}
}
